package com.bbx.taxi.client.Fragment;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import net.simonvt.menudrawer.MenuDrawer;

import cn.king.swipelibrary.SwipeLayout;
import cn.king.swipelibrary.SwipeLayout.Status;

import com.baidu.location.BDLocation;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Combo;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Combo.ComboInfo;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Price;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Vehicle.VehicleList;
import com.bbx.api.sdk.model.passanger.Return.Elements;
import com.bbx.api.sdk.model.passanger.Return.Info;
import com.bbx.api.sdk.model.passanger.Return.OrderId;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.End;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Location;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Locations;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Start;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.passeger.conn.CodeNet;
import com.bbx.api.sdk.net.passeger.conn.OrderSubmitNet;
import com.bbx.api.util.LogUtils;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.Task.MyComboTask;
import com.bbx.taxi.client.Task.MyComboTask.OnComboListener;
import com.bbx.taxi.client.Task.MyVclassTask;
import com.bbx.taxi.client.Task.MyVclassTask.OnVclassListener;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.Activity.ContactPersonActivity;
import com.bbx.taxi.client.Activity.FareDetailsActivity;
import com.bbx.taxi.client.Activity.LeaveMessageActivity;
import com.bbx.taxi.client.Activity.MainActivity.MyOnTouchListener;
import com.bbx.taxi.client.Activity.MainActivity.OnActivityResultListener;
import com.bbx.taxi.client.Activity.MainActivity.OnPriceListener;
import com.bbx.taxi.client.Activity.MainActivity.OnSwitchButtonListener;
import com.bbx.taxi.client.Activity.PlaneActivity;
import com.bbx.taxi.client.Activity.MainActivity;
import com.bbx.taxi.client.Activity.MainActivity.MyOnPageScrolledListener;
import com.bbx.taxi.client.Activity.MainActivity.OnMenuClickListener;
import com.bbx.taxi.client.Activity.Order.StartServiceActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity.CodeTask;
import com.bbx.taxi.client.Activity.Address.EditAddressActivity;
import com.bbx.taxi.client.Activity.Base.BaseFragment;
import com.bbx.taxi.client.Adapter.Page.MyPagerAdapter;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute.OnContentFillingListener;
import com.bbx.taxi.client.Bean.Extra.AddressMsg;
import com.bbx.taxi.client.Bean.Extra.ContactPersonMsg;
import com.bbx.taxi.client.Bean.Extra.FareDetailsMsg;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.DB.Util.DBcolumns;
import com.bbx.taxi.client.Fragment.CityCarFragment.OnTelInterfaceListener;
import com.bbx.taxi.client.MyApplication.OnLocationResultListener;
import com.bbx.taxi.official.R;
import com.bbx.taxi.client.Util.ClickFilter;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.IsViewOutArea;
import com.bbx.taxi.client.widget.MyViewPager;
import com.bbx.taxi.client.widget.ScrollView.BounceHorizontalScrollView;
import com.bbx.taxi.client.widget.ScrollView.MyHorizontalScrollView;
import com.bbx.taxi.client.widget.ScrollView.MyHorizontalScrollView.ScrollViewListener;
import com.bbx.taxi.client.widget.SwitchButton.Configuration;
import com.bbx.taxi.client.widget.SwitchButton.SwitchButton;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop.OnAddressItemClickListener;
import com.bbx.taxi.client.widget.pop.DatePicker;
import com.bbx.taxi.client.widget.pop.DatePicker.OnConfirmListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnDateConfirmListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnDateScrollResultListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnPeopleScrollResultListener;
import com.bbx.taxi.client.widget.pop.WheelCustom;
import com.bbx.taxi.client.widget.pop.WheelCustom.OnWheelCustomSelectedListener;
import com.example.Util.DensityUtil;
import com.example.mydatepicker.wheelview.WheelView;
import com.example.mylistview.swipemenu.MyListView;
import com.example.mylistview.swipemenu.SwipeMenu;
import com.example.mylistview.swipemenu.SwipeMenuCreator;
import com.example.mylistview.swipemenu.SwipeMenuItem;
import com.example.mylistview.swipemenu.MyListView.OnMenuItemClickListener;
import com.example.mylistview.swipemenu.MyListView.OnSwipeListener;
import com.bbx.taxi.client.Adapter.PointAdapter;

import android.animation.LayoutTransition;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @Path com.bbx.taxi.client.Fragment.Official.java
 * @Author 严旭文
 * @Date 2016-1-14 下午12:37:06
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class OfficialFragment extends BaseFragment implements OnClickListener,
		OnMenuClickListener, MyOnPageScrolledListener, OnVclassListener,
		OnWheelCustomSelectedListener, OnComboListener, OnPriceListener,
		OnActivityResultListener, MyOnTouchListener ,ScrollViewListener,OnSwitchButtonListener{
	private MyHorizontalScrollView horizontalscrollview;
	private LinearLayout layout_scroll, layout_scroll2;
	private RelativeLayout timelayout;
	private RelativeLayout personlayout;
	private RelativeLayout layout_message;
	private RelativeLayout layout_driver;
	private TextView tv_time;
	private TextView tv_start;
	private TextView tv_end;
	private RelativeLayout layout_start_end;
	public TextView tv_telephone;
	private TextView tv_message;
	private Context mContext;
	private CheckBox cb_wf;
	private RelativeLayout layout_wf;
	public TextView tv_combo;
	private RelativeLayout layout_estimate_price;
	private TextView tv_estimate_price;
	private TextView tv_taxi_price;
	private MyApplication mApplication;
	/** 主界面的信息临时存储 */
	private MainAttribute main;
	private MainActivity mainActivity;
	private LinearLayout layout_parent;
	private ImageButton iv_add_point;
	private List<SwipeLayout> list_point;
	private ImageView iv_more_left,iv_more_right;
	/** 车辆集合外布局 */
	private List<View> list_layout = new ArrayList<View>();
	/** 车辆集合_标题 */
	private List<TextView> list_text = new ArrayList<TextView>();
	/** 车辆集合_图片 */
	private List<ImageView> list_icon = new ArrayList<ImageView>();
	/** 车辆集合_选中 */
	// private List<CheckBox> list_cb = new ArrayList<CheckBox>();
	private int width;
	private int scrollViewMeasuredWidth;
	private int scrollx;
	private int srcollviewwidth;
	/**隐藏出租车，在Value里面list_vtype也要隐藏*/
	private static int icon_car1_down = R.drawable.icon_car1_down;
	private static int icon_car2_down = R.drawable.icon_car2_down;
	private static int icon_car3_down = R.drawable.icon_car3_down;
	private static int icon_car4_down = R.drawable.icon_car4_down;
//	private static int icon_car5_down = R.drawable.icon_car5_down;
	private int icon_car1_nor = R.drawable.icon_car1_nor;
	private int icon_car2_nor = R.drawable.icon_car2_nor;
	private int icon_car3_nor = R.drawable.icon_car3_nor;
	private int icon_car4_nor = R.drawable.icon_car4_nor;
//	private int icon_car5_nor = R.drawable.icon_car5_nor;
	private int[] icon_car_nor = new int[] { /**icon_car5_nor,*/ icon_car1_nor,
			icon_car2_nor, icon_car3_nor, icon_car4_nor };
	public static int[] icon_car_down = new int[] { /**icon_car5_down,*/
			icon_car1_down, icon_car2_down, icon_car3_down, icon_car4_down };
	public static int[] car_name = new int[] {/** R.string.texi_car,*/
			R.string.business_car, R.string.business_suv,
			R.string.business_minibuses, R.string.business_bus };
	/** vtype各种类型 */

	public static final int default_cb_position = 0;
	/** 选中的选项 */
	public static int cb_position = default_cb_position;

	public static final int default_old_position = -100;
	/** 旧的选择选项 */
	public static int old_position = default_old_position;
	/** 判断是否是自动读取套餐价格 */
	private boolean isautomatic = false;
	private Officail_Price mOfficail_Price;
	// 途径点打开的删除的id
	private int open_id = -1;

	public void onCreateView(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_official);
		mApplication = MyApplication.getInstance();
		mContext = mApplication.getApplicationContext();
		main = MainAttribute.getInstance();
		mainActivity = (MainActivity) getActivity();
		mainActivity.setMyOnPageScrolledListener(this);
		mainActivity.setOnActivityResultListener(this);
		mainActivity.setOnSwitchButtonListener(this);
		init();
		initView();
		list_point = new ArrayList<SwipeLayout>();
		LayoutTransition transition = new LayoutTransition();
		transition.setAnimator(LayoutTransition.CHANGE_APPEARING,
				transition.getAnimator(LayoutTransition.CHANGE_APPEARING));
		transition.setAnimator(LayoutTransition.APPEARING, null);
		transition.setAnimator(LayoutTransition.DISAPPEARING,
				transition.getAnimator(LayoutTransition.DISAPPEARING));
		transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING,
				transition.getAnimator(LayoutTransition.CHANGE_DISAPPEARING));
		layout_parent.setLayoutTransition(transition);
	}

	private void init() {
		mainActivity.setOnPriceListener(this);
		layout_estimate_price = (RelativeLayout) findViewById(R.id.layout_estimate_price);
		tv_estimate_price = (TextView) findViewById(R.id.tv_estimate_price);
		tv_estimate_price.setTypeface(Typeface.createFromAsset(mainActivity.getAssets(),"fonts/num.ttf"));
		tv_taxi_price = (TextView) findViewById(R.id.tv_taxi_price);
		cb_wf = (CheckBox) findViewById(R.id.cb_wf);
		layout_wf=(RelativeLayout) findViewById(R.id.layout_wf);
		horizontalscrollview = (MyHorizontalScrollView) findViewById(R.id.horizontalscrollview);
		horizontalscrollview.setScrollViewListener(this);
		layout_scroll = (LinearLayout) findViewById(R.id.layout_scroll);
		layout_scroll2 = (LinearLayout) findViewById(R.id.layout_scroll2);
		tv_time = (TextView) findViewById(R.id.tv_time);
		tv_start = (TextView) findViewById(R.id.tv_start);
		tv_end = (TextView) findViewById(R.id.tv_end);
		tv_telephone = (TextView) findViewById(R.id.tv_telephone);
		tv_message = (TextView) findViewById(R.id.tv_message);
		timelayout = (RelativeLayout) findViewById(R.id.timelayout);
		personlayout = (RelativeLayout) findViewById(R.id.personlayout);
		layout_message = (RelativeLayout) findViewById(R.id.layout_message);
		layout_driver = (RelativeLayout) findViewById(R.id.layout_driver);
		tv_combo = (TextView) findViewById(R.id.tv_combo);
		iv_add_point = (ImageButton) findViewById(R.id.iv_add_point);
		layout_parent = (LinearLayout) findViewById(R.id.layout_parent);
		layout_start_end = (RelativeLayout) findViewById(R.id.layout_start_end);
		iv_more_left=(ImageView) findViewById(R.id.iv_more_left);
		iv_more_right=(ImageView) findViewById(R.id.iv_more_right);
		timelayout.setOnClickListener(this);
		personlayout.setOnClickListener(this);
		tv_start.setOnClickListener(this);
		tv_end.setOnClickListener(this);
		layout_message.setOnClickListener(this);
		layout_driver.setOnClickListener(this);
		layout_estimate_price.setOnClickListener(this);
		iv_add_point.setOnClickListener(this);
		horizontalscrollview.setOnTouchListener(new TouchListenerImpl());
		MainActivity.setOnMenuClickListener(this);
		WindowManager wm = (WindowManager) mainActivity.getBaseContext()
				.getSystemService(Context.WINDOW_SERVICE);
		width = wm.getDefaultDisplay().getWidth();
		cb_wf.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				main.setWf(isChecked);

			}
		});
		initCar();
		showIsOwn();

	}

	/**
	 * 添加途径点滑动监听
	 */
	public void addPointListener() {

		for (int i = 0; i < list_point.size(); i++) {
			final int position = i;
			final SwipeLayout mSwipeLayout = list_point.get(position);
			mSwipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
			mSwipeLayout.removeAllSwipeListener();//由于是内部内，会导致addSwipeListener重复添加，所以每次添加的时候要清空一下
			mSwipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
				@Override
				public void onClose(SwipeLayout arg0) {
					// 如果打开项跟关闭项同一个的话，则执行隐藏菜单，并清空数据
					// 如果打开项跟关闭项不同个的话，则不执行任何操作。
					if (position == open_id) {
						hideMenuDel();
					}
				}

				@Override
				public void onHandRelease(SwipeLayout arg0, float arg1,
						float arg2) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onOpen(SwipeLayout arg0) {
					showMenuDel(position);

				}

				@Override
				public void onUpdate(SwipeLayout arg0, int arg1, int arg2) {
					// TODO Auto-generated method stub

				}
			});
			RelativeLayout iv_delete = (RelativeLayout) mSwipeLayout
					.findViewById(R.id.iv_delete);
			iv_delete.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					removePoint(list_point.get(position));
				}
			});
			ImageButton iv_add_point = (ImageButton) mSwipeLayout
					.findViewById(R.id.iv_add_point);
			iv_add_point.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					addPoint();
				}
			});
			RelativeLayout layout_point = (RelativeLayout) mSwipeLayout
					.findViewById(R.id.layout_point);
			layout_point.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					if (mSwipeLayout.getOpenStatus() == Status.Open) {
						hideMenuDel();
					} else if (open_id != -1) {
						hideMenuDel();
					} else {
						startActivityForResult(
								new Intent(mContext, EditAddressActivity.class)
										.putExtra(AddressMsg.extra_editaddress,
												AddressMsg.ADDRESS_POINT)
										.putExtra(AddressMsg.extra_point_id,
												position),
								MainAttribute.REQUEST_CODE_POINT_ADDRESS);
					}

				}
			});
			layout_point.setOnTouchListener(new OnTouchListener() {

				@Override
				public boolean onTouch(View arg0, MotionEvent arg1) {
					switch (arg1.getAction()) {
					case MotionEvent.ACTION_DOWN:
						//每次点击途径点的时候则要添加Touch监听，以便于区别是途经点区域外还是区域内
						mainActivity
								.registerMyOnTouchListener(OfficialFragment.this);
						break;
					}
					return false;
				}
			});
			if (position == 0) {
				iv_add_point.setVisibility(View.VISIBLE);
			}
		}

	}

	/**
	 * 初始化车辆信息
	 */
	public void initCar() {
		list_layout.clear();
		list_text.clear();
		list_icon.clear();
		// list_cb.clear();
		int column = 3;// 列数
		// 加载汽车集合
		int total = car_name.length;
		LayoutInflater mInflater = mainActivity.getLayoutInflater();// 获取mInflater，用于加载布局

		for (int i = 0; i < total; i++) {
			View car_content = mInflater.inflate(R.layout.car_content, null);// 加载布局
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);

			lp.gravity = Gravity.CENTER;
			list_layout.add(car_content);
			if (total < column) {
				lp.width = width / total;
				car_content.setLayoutParams(lp);
				layout_scroll2.addView(car_content);
			} else {
				lp.width = width / column;
				car_content.setLayoutParams(lp);
				layout_scroll.addView(car_content);
			}
		}

		if (list_layout.size() > 0) {
			for (int i = 0; i < list_layout.size(); i++) {
				final int position = i;
				list_layout.get(i).setOnTouchListener(new OnTouchListener() {

					@Override
					public boolean onTouch(View view, MotionEvent motionEvent) {
						switch (motionEvent.getAction()) {
						case MotionEvent.ACTION_DOWN:
							isScroll();
							break;
						}
						return false;
					}
				});
				list_layout.get(i).setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						if (mApplication.isUidAndTokenNull()) {
							Intent intent = new Intent(mainActivity,
									LoginActivity.class);
							intent.putExtra(MainMsg.extra_login,
									MainMsg.INTENT_LOGIN);
							intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
							startActivity(intent);
						} else {
							isScroll();
							for (int j = 0; j < list_layout.size(); j++) {
								list_icon.get(j).setImageDrawable(
										mainActivity.getResources()
												.getDrawable(icon_car_nor[j]));
								list_text.get(j).setTextColor(
										mainActivity.getResources().getColor(
												R.color.text_nor));
								list_text.get(j).setText(car_name[j]);
							}
							int vtype = Value.list_vtype[position];
							// if (mainActivity.map_vclass.get(vtype) != null
							// && !mainActivity.map_vclass.get(vtype)
							// .isEmpty()) {
							// onVclass(position, vtype, 0,
							// mainActivity.map_vclass.get(vtype),
							// false);
							// } else {
							MyVclassTask.getInstance(mainActivity,
									mApplication, position, vtype, 0, false)
									.setOnVclassListener(OfficialFragment.this);
							// }
						}
					}
				});
				TextView tv_title = (TextView) list_layout.get(i).findViewById(
						R.id.tv_car);
				tv_title.setText(mainActivity.getString(car_name[i]));
				list_text.add(tv_title);
				ImageView iv_icon = (ImageView) list_layout.get(i)
						.findViewById(R.id.iv_icon);
				iv_icon.setImageDrawable(mainActivity.getResources()
						.getDrawable(icon_car_nor[i]));
				list_icon.add(iv_icon);
			}

			if (mApplication.isUidAndTokenNull()) {

			} else {
				// 初始化改显示的汽车类型，第一次则是默认第一个，重新下单根据类型
				int position = 0;
				for (int i = 0; i < Value.list_vtype.length; i++) {
					if (Integer.parseInt(main.getVtype()) == Value.list_vtype[i]) {
						position = i;
						cb_position = position;
						break;
					}
				}
				// setDownCarTypeColor(position);
				// 如果是第一次启动则先获取车型列表在自动获取套餐价格，如果是再次下单则直接获取
				if (mApplication.isFirstActivity) {
					// 默认读取第一辆车的第一个level的套餐价
					MyVclassTask.getInstance(mainActivity, mApplication,
							cb_position, Integer.parseInt(main.getVtype()),
							main.getVtypeIndex(), true).setOnVclassListener(
							OfficialFragment.this);
				} else {
					// 报错的原因是，由通知点击进来的，和登陆界面点击返回回来的，，不需要变化
					try {
						MyVclassTask.getInstance(mainActivity, mApplication,
								cb_position, Integer.parseInt(main.getVtype()),
								main.getVtypeIndex(), true)
								.setOnVclassListener(OfficialFragment.this);
					} catch (Exception e) {
					}

				}
			}
		}

	}

	public void initView() {
		main = MainAttribute.getInstance();
		mainActivity = (MainActivity) getActivity();
		if (main != null && tv_time != null) {
			// 时间
			tv_time.setText(main.getTime());
			// 出发地
			if (main.getStartName() != null) {
				tv_start.setText(main.getStartName());
			}
			// 目的地
			if (main.getEndName() != null) {
				tv_end.setText(main.getEndName());
			}
			// 姓名和电话
			if (main.getName() != null && main.getTel() != null
					&& !main.getTel().equals("")) {
				tv_telephone.setText((main.getName().equals("") ? mApplication
						.getRealName() : main.getName())
						+ "-"
						+ FormatUtil.onFormatTelephone(main.getTel()));
			}
			// 留言
			if (main.getMessage_GW() != null) {
				tv_message.setText(main.getMessage_GW());
			} else {
				tv_message.setText("");
			}
			if (main.getWf()) {
				cb_wf.setChecked(true);
			} else {
				cb_wf.setChecked(false);
			}
		}
	}

	@Override
	public void onPrice(Officail_Price mOfficail_Price, boolean isVisible,
			boolean isTaxi) {
		this.mOfficail_Price = mOfficail_Price;
		if (isTaxi) {
			tv_taxi_price.setVisibility(View.VISIBLE);
			layout_estimate_price.setVisibility(View.INVISIBLE);
			return;
		} else {
			tv_taxi_price.setVisibility(View.GONE);
		}
		if (layout_estimate_price == null && mOfficail_Price == null)
			return;
		if (isVisible) {
			layout_estimate_price.setVisibility(View.VISIBLE);
			tv_estimate_price.setText(FormatUtil.onFormatPrice(mOfficail_Price
					.getPrice()));
		} else {
			layout_estimate_price.setVisibility(View.INVISIBLE);
		}
	};

	@Override
	public void onClick(View v) {
		if (!ClickFilter.filter())
			return;
		switch (v.getId()) {
		case R.id.timelayout:
			DatePicker.getInstance(mContext).onShow(v, 2);
			DatePicker.getInstance(mContext).setOnDateScrollResultListener(
					new OnDateScrollResultListener() {
						@Override
						public void OnDateScrollResult(List<String> list,
								List<String> list_min, WheelView wl_day,
								WheelView wl_hour, WheelView wl_min) {
							switch (wl_day.getCurrentItem()) {
							case 0://
								wl_hour.setCurrentItem(0, true);
								wl_min.setCurrentItem(0, true);
								break;
							case 1:// 今天，滑动到当前时间
								long Time = DateFormat.getTime() + 30 * 60 * 1000;// 加20分上去，是为了不让选择当前时间+30分以下的时间
								Calendar mCalendar = Calendar.getInstance();
								mCalendar.setTimeInMillis(Time);
								int hour = mCalendar.get(Calendar.HOUR_OF_DAY);
								int minute = mCalendar.get(Calendar.MINUTE);
								if ((wl_hour.getCurrentItem() - 1) <= (hour)) {
									wl_hour.setCurrentItem(hour + 1, true);
									if (wl_min.getCurrentItem() == 0
											|| Integer.parseInt(list_min
													.get(wl_min
															.getCurrentItem())) <= (minute)) {
										int index = 0;
										for (int i = 1; i < list_min.size(); i++) {
											int min = Integer.parseInt(list_min
													.get(i));
											if (minute == min) {
												index = i;
												break;
											} else {
												if (minute > min
														&& (minute - min < 5)) {
													index = i + 1;
													break;
												} else if (minute < 5) {// 0~4的时候要当中是5分钟
													index = 1;
													break;
												} else if ((60 - minute) < 5) {// 55~59的时候也要当中是5分钟
													index = 1;
													wl_hour.setCurrentItem(hour + 2, true);
													break;
												}

											}
										}
										wl_min.setCurrentItem(index, true);
									}
								}else{
									if(wl_min.getCurrentItem()==0){
										wl_min.setCurrentItem(1,true);
									}
								}
								break;
							default:
								if (wl_hour.getCurrentItem() == 0) {
									wl_hour.setCurrentItem(1, true);
								}
								if (wl_min.getCurrentItem() == 0) {
									wl_min.setCurrentItem(1, true);
								}
								break;
							}
						}
					});
			DatePicker.getInstance(mContext).setOnDateConfirmListener(
					new OnDateConfirmListener() {
						@Override
						public void onDateConfirm(List<String> list,
								List<String> list_min, WheelView wl_day,
								WheelView wl_hour, WheelView wl_min,
								int estimate_time) {
							if (wl_day.getCurrentItem() == 0) {
								main.setTime(list.get(wl_day.getCurrentItem()));
								tv_time.setText(main.getTime());
								return;
							}
							int min=0;
							try{
								min=Integer.parseInt(list_min
										.get(wl_min
												.getCurrentItem()));
							}catch(Exception e){}
							
							main.setTime(DatePicker
									.getInstance(mContext)
									.onTimeFormat(
											list.get(wl_day.getCurrentItem()),
											wl_hour.getCurrentItem() - 1,
											min));
							tv_time.setText(main.getTime());
						}
					});
			break;
		case R.id.personlayout:
			if (mApplication.isUidAndTokenNull()) {
				Intent intent = new Intent(mainActivity, LoginActivity.class);
				intent.putExtra(MainMsg.extra_login, MainMsg.INTENT_LOGIN);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			} else {
				personlayout.setClickable(false);
				startActivityForResult(
						new Intent(mContext, ContactPersonActivity.class)
								.putExtra(ContactPersonMsg.extra_contact_name,
										main.getName()).putExtra(
										ContactPersonMsg.extra_contact_phone,
										main.getTel()),
						MainAttribute.REQUEST_CODE_PERSON);
			}
			break;
		case R.id.tv_start:
			tv_start.setClickable(false);
			startActivityForResult(
					new Intent(mContext, EditAddressActivity.class).putExtra(
							AddressMsg.extra_editaddress,
							AddressMsg.ADDRESS_START_MAIN).putExtra(
							AddressMsg.extra_cityopend,
							mainActivity.getCityNotOpened(false)),
					MainAttribute.REQUEST_CODE_START_ADDRESS);
			break;
		case R.id.tv_end:
			tv_end.setClickable(false);
			startActivityForResult(new Intent(mContext,
					EditAddressActivity.class).putExtra(
					AddressMsg.extra_editaddress, AddressMsg.ADDRESS_END_MAIN),
					MainAttribute.REQUEST_CODE_END_ADDRESS);
			break;
		case R.id.layout_convert:
			main.onSwap();
			tv_start.setText(main.getStartName());
			tv_end.setText(main.getEndName());
			break;
		case R.id.layout_message:
			startActivityForResult(new Intent(mContext,
					LeaveMessageActivity.class).putExtra(MainMsg.extra_message,
					MainMsg.MESSAGE_MAIN_GW),
					MainAttribute.REQUEST_CODE_MESSAGE);
			break;
		case R.id.layout_driver:
			break;

		case R.id.layout_start_collecte:
			CollecteAddressPop.getInstance(mContext).onShow(v);
			CollecteAddressPop.getInstance(mContext).setOnItemClickListener(
					new OnAddressItemClickListener() {
						@Override
						public void onItemClick(List<Map<String, String>> list,
								int position) {
							main.setStartName(list.get(position).get(
									DBcolumns.ADDRESS_NAME));
							main.setStartCity(list.get(position).get(
									DBcolumns.ADDRESS_CITY));
							main.setStartAddress(list.get(position).get(
									DBcolumns.ADDRESS_ADDRESS));
							main.setStartLongitude(Double.parseDouble(list.get(
									position).get(DBcolumns.ADDRESS_LONGITUDE)));
							main.setStartLatitude(Double.parseDouble(list.get(
									position).get(DBcolumns.ADDRESS_LATITUDE)));
							if (!main.getStartName().equals("")) {
								tv_start.setText(main.getStartName());
							}
						}
					});
			break;
		case R.id.layout_end_collecte:
			CollecteAddressPop.getInstance(mContext).onShow(v);
			CollecteAddressPop.getInstance(mContext).setOnItemClickListener(
					new OnAddressItemClickListener() {
						@Override
						public void onItemClick(List<Map<String, String>> list,
								int position) {
							main.setEndName(list.get(position).get(
									DBcolumns.ADDRESS_NAME));
							main.setEndCity(list.get(position).get(
									DBcolumns.ADDRESS_CITY));
							main.setEndAddress(list.get(position).get(
									DBcolumns.ADDRESS_ADDRESS));
							main.setEndLongitude(Double.parseDouble(list.get(
									position).get(DBcolumns.ADDRESS_LONGITUDE)));
							main.setEndLatitude(Double.parseDouble(list.get(
									position).get(DBcolumns.ADDRESS_LATITUDE)));
							if (!main.getEndName().equals("")) {
								tv_end.setText(main.getEndName());
							}
						}
					});
			break;
		case R.id.layout_estimate_price:
			String price = "";
			String start_price = "";
			String mileprice = "";
			String minuteprice = "";
			String mile = "";
			String minute = "";
			String vtype = "";
			String vtypeTitle = "";
			try {
				if (mOfficail_Price != null
						&& mOfficail_Price.getPriceDetail() != null) {
					price = mOfficail_Price.getPrice() + "";
					mileprice = mOfficail_Price.getPriceDetail().getMileprice()
							+ "";
					minuteprice = mOfficail_Price.getPriceDetail()
							.getMinuteprice() + "";
					start_price = mOfficail_Price.getPriceDetail()
							.getStart_price();
					mile = mOfficail_Price.getPriceDetail().getMiles() + "";
					minute = mOfficail_Price.getPriceDetail().getMinutes() + "";
					vtype = main.getVtype();
					vtypeTitle = main.getVtypeTitle();
				}

			} catch (Exception e) {
			}
			startActivity(new Intent(mainActivity, FareDetailsActivity.class)
					.putExtra(FareDetailsMsg.MSG_PRICE,
							FormatUtil.onFormatPrice(price))
					.putExtra(FareDetailsMsg.MSG_MILEPRICE,
							FormatUtil.onFormatPrice(mileprice))
					.putExtra(FareDetailsMsg.MSG_MINUTEPRICE,
							FormatUtil.onFormatPrice(minuteprice))
					.putExtra(FareDetailsMsg.MSG_START_PRICE,
							FormatUtil.onFormatPrice(start_price))
					.putExtra(FareDetailsMsg.MSG_MILE,
							FormatUtil.onFormatDistance(mile))
					.putExtra(FareDetailsMsg.MSG_MINUTE, minute)
					.putExtra(FareDetailsMsg.MSG_VTYPE, vtype)
					.putExtra(FareDetailsMsg.MSG_VTYPETITLE, vtypeTitle));
			break;
		case R.id.iv_add_point:
			addPoint();
			break;
//		case R.id.iv_zhankai:
//			if (list_point.size() > 0) {
//				if (list_point.get(0).getVisibility() == View.GONE) {
//					for (int i = 0; i < list_point.size(); i++) {
//						list_point.get(i).setVisibility(View.VISIBLE);
//					}
//					iv_zhankai.setBackgroundDrawable(mContext.getResources()
//							.getDrawable(R.drawable.btn_ddsh_up));
//				} else {
//					for (int i = list_point.size() - 1; i >= 0; i--) {
//						list_point.get(i).setVisibility(View.GONE);
//					}
//					iv_zhankai.setBackgroundDrawable(mContext.getResources()
//							.getDrawable(R.drawable.btn_ddsh_don));
//				}
//			}
//
//			break;

		}
	}

	public boolean onLocationResult() {
		boolean isError = false;
		if (tv_start != null) {
			tv_start.setText(main.getStartName());
		} else {
			isError = true;
		}
		return isError;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		switch (requestCode) {
		case MainAttribute.REQUEST_CODE_PERSON:// 电话
			personlayout.setClickable(true);
			if (data != null) {
				main.setTel(data.getStringExtra("telephone"));
				main.setName(data.getStringExtra("name"));
				if (main.getName() != null && main.getTel() != null
						&& !main.getName().equals("")
						&& !main.getTel().equals("")) {
					tv_telephone.setText(main.getName() + "-"
							+ FormatUtil.onFormatTelephone(main.getTel()));
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_START_ADDRESS:// 出发地
			tv_start.setClickable(true);
			if (data != null) {
				main.setStartCity(data
						.getStringExtra(AddressMsg.extra_address_city));
				main.setStartAddress(data
						.getStringExtra(AddressMsg.extra_address_address));
				main.setStartLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0));
				main.setStartLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0));
				main.setStartName(data
						.getStringExtra(AddressMsg.extra_address_name));
				if (!main.getStartName().equals("")) {
					tv_start.setText(main.getStartName());
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_END_ADDRESS:
			tv_end.setClickable(true);
			if (data != null) {

				main.setEndCity(data
						.getStringExtra(AddressMsg.extra_address_city));
				main.setEndAddress(data
						.getStringExtra(AddressMsg.extra_address_address));
				main.setEndLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0));
				main.setEndLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0));
				main.setEndName(data
						.getStringExtra(AddressMsg.extra_address_name));
				if (!main.getEndName().equals("")) {
					tv_end.setText(main.getEndName());
				}
				LogUtils.e("",
						data.getStringExtra(AddressMsg.extra_address_address));
			}
			break;
		case MainAttribute.REQUEST_CODE_POINT_ADDRESS:// 途经点
			if (data != null) {
				String point_city = data
						.getStringExtra(AddressMsg.extra_address_city);
				String point_address = data
						.getStringExtra(AddressMsg.extra_address_address);
				double point_lng = data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0);
				double point_lat = data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0);
				String point_name = data
						.getStringExtra(AddressMsg.extra_address_name);
				int point_id = data.getIntExtra(
						AddressMsg.extra_address_point_id, 0);
				if (!point_name.equals("")) {
					TextView tv_point = (TextView) list_point.get(point_id)
							.findViewById(R.id.tv_point);
					tv_point.setText(point_name);

				}
				LogUtils.e("",
						data.getStringExtra(AddressMsg.extra_address_address));
			}
			break;
		case MainAttribute.REQUEST_CODE_MESSAGE:
			if (data != null) {
				main.setMessage_GW(data.getStringExtra("message"));
				initView();
			}
			break;
		}
		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	public void OnMenuClick() {
		initView();
	}

	@Override
	public void onPageScrolled(int viewid) {
		if (viewid == Value.VIEWID_GW) {
			initView();
		}
	}

	private class TouchListenerImpl implements OnTouchListener {
		@Override
		public boolean onTouch(View view, MotionEvent motionEvent) {
			scrollx = view.getScrollX();
			srcollviewwidth = view.getWidth();
			switch (motionEvent.getAction()) {
			case MotionEvent.ACTION_DOWN:
			case MotionEvent.ACTION_MOVE:
				scrollViewMeasuredWidth = horizontalscrollview.getChildAt(0)
						.getMeasuredWidth();
				isScroll();
				break;
			case MotionEvent.ACTION_CANCEL:
			case MotionEvent.ACTION_UP:
				mainActivity.mMenuDrawer
						.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
			default:

				break;
			}
			return false;
		}

	}

	public void isScroll() {
		if (scrollx == 0) {
			mainActivity.mMenuDrawer
					.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
		} else {
			mainActivity.mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_NONE);
		}
		if ((scrollx + width) == scrollViewMeasuredWidth) {
		}
	}

	/**
	 * 设置默认车型，用于在MainActivity里onActivityResult调用
	 */
	public void setDefaultCar() {
		tv_combo.setText(main.getComboPrice());
		for (int i = 0; i < list_layout.size(); i++) {
			list_icon.get(i).setImageDrawable(
					mainActivity.getResources().getDrawable(icon_car_nor[i]));
			list_text.get(i).setTextColor(
					mainActivity.getResources().getColor(R.color.text_nor));
			list_text.get(i).setText(car_name[i]);
		}

		int position = 0;
		for (int i = 0; i < Value.list_vtype.length; i++) {
			if (Integer.parseInt(main.getVtype()) == Value.list_vtype[i]) {
				position = i;
				break;
			}
		}
		if (list_layout.get(position).isEnabled()) {
			setDownCarTypeColor(position);
			setCarTextBule(position);
		}
	}

	/**
	 * 设置上一个车型，获取失败的时候调用
	 */
	public void setPrevCar(int type) {
		switch (type) {
		case 0:
			ToastUtil.showToast(mainActivity, R.string.no_vclass);
			break;
		case 1:
			ToastUtil.showToast(mainActivity, R.string.vclass_no_available);
			break;
		}
		main.onRestorePrevCar();
		for (int j = 0; j < list_layout.size(); j++) {
			list_icon.get(j).setImageDrawable(
					mainActivity.getResources().getDrawable(icon_car_nor[j]));
			list_text.get(j).setTextColor(
					mainActivity.getResources().getColor(R.color.text_nor));
			list_text.get(j).setText(car_name[j]);
		}
		if (old_position >= 0 && old_position != cb_position) {
			setDownCarTypeColor(old_position);
			// 添加汽车具体的类型文字说明
			setCarTextBule(old_position);
		} else {
			mainActivity.setConfirm(false);
		}
	}

	@Override
	public void onWheelCustomSelected(List<String> list, int vtype,
			int vtype_index) {
		if (vtype_index < 0) {
			for (int j = 0; j < list_layout.size(); j++) {
				list_icon.get(j).setImageDrawable(
						mainActivity.getResources()
								.getDrawable(icon_car_nor[j]));
				list_text.get(j).setTextColor(
						mainActivity.getResources().getColor(R.color.text_nor));
				list_text.get(j).setText(car_name[j]);
			}
			if (old_position >= 0) {
				setDownCarTypeColor(old_position);
				// 添加汽车具体的类型文字说明
				setCarTextBule(old_position);
			}
		} else {
			setCarDetail(vtype, vtype_index);
		}

	}

	@Override
	public void onVclass(int cb_position, int vtype, int vtype_index,
			ArrayList<VehicleList> list, boolean isautomatic) {
		this.isautomatic = isautomatic;
		this.cb_position = cb_position;
		MainActivity.map_vclass.clear();
		// 自动的，自动读取套餐价格
		if (isautomatic) {
			MainActivity.map_vclass.put(vtype, list);
			if (list != null && !list.isEmpty() && list.size() >= 1) {
				setDownCarTypeColor(cb_position);
				setCarDetail(vtype, vtype_index);
				// 再次下单会走这一步，必须车型可以正常加载，才开始启动自动判断是否填满信息
				main.isNoListener = false;
				main.onContentFilling();
			} else {
				// ToastUtil.showToast(mainActivity, R.string.no_vclass);
				list_icon.get(cb_position).setImageDrawable(
						mainActivity.getResources().getDrawable(
								icon_car_nor[cb_position]));
				list_text.get(cb_position).setTextColor(
						mainActivity.getResources().getColor(R.color.text_nor));
				list_text.get(cb_position).setText(car_name[cb_position]);
				// list_layout.get(cb_position).setEnabled(false);
				setPrevCar(0);
			}
		} else {
			main.isNoListener = false;
			if (list != null && !list.isEmpty()) {
				MainActivity.map_vclass.put(vtype, list);
				List<String> list_type = new ArrayList<String>();
				if (vtype <= 2) {
					for (int i = 0; i < list.size(); i++) {
						switch (Integer.parseInt(list.get(i).getLevel())) {
						case 1:
							list_type.add(Value.car_type[0]);
							break;
						case 2:
							list_type.add(Value.car_type[1]);
							break;
						case 3:
							list_type.add(Value.car_type[2]);
							break;
						}

					}
				} else {
					for (int i = 0; i < list.size(); i++) {
						list_type.add(list.get(i).getSeat_Num() + "座");
					}
				}
				if (list.size() == 1) {// 如果只有1中类型的话，默认直接加载套餐价格
					setCarDetail(vtype, 0);
				} else {
					WheelCustom.getInstance(mainActivity).onShow(layout_scroll,
							list_type, vtype);
					WheelCustom.getInstance(mainActivity)
							.setOnSelectedListener(OfficialFragment.this);
				}
				setDownCarTypeColor(cb_position);
			} else {
				setPrevCar(0);
			}
		}

	}

	/**
	 * 设置车辆信息，并加载套餐价格
	 */
	public void setCarDetail(int vtype, int vtype_index) {
		ArrayList<VehicleList> list_vehicle = MainActivity.map_vclass
				.get(vtype);
		if(list_vehicle==null||list_vehicle.isEmpty())return;
		// 自动读取套餐价格的时候，默认汽车类型为1
		main.setLevelCar(list_vehicle.get(vtype_index).getLevel());

		main.setSeat_num(list_vehicle.get(vtype_index).getSeat_Num());
		main.setVtype(list_vehicle.get(vtype_index).getVtype());
		main.setVtypeId(list_vehicle.get(vtype_index).getClass_Id());
		main.setTc_id(list_vehicle.get(vtype_index).getTc_id());
		switch (vtype) {
		case 1:
		case 2:
			String type = "";
			switch (Integer.parseInt(list_vehicle.get(vtype_index).getLevel())) {
			case 1:
				type = Value.car_type[0];
				break;
			case 2:
				type = Value.car_type[1];
				break;
			case 3:
				type = Value.car_type[2];
				break;
			}
			main.setVtypeTitle(mainActivity.getString(car_name[cb_position])
					+ " " + type);
			break;

		case 3:
		case 4:
		case 5:
			main.setVtypeTitle(mainActivity.getString(car_name[cb_position])
					+ " " + list_vehicle.get(vtype_index).getSeat_Num() + "座");
			break;
		}
		
		 MyComboTask.getInstance(mainActivity,list_vehicle.get(vtype_index), mApplication).setOnComboListener(
				 this);
	}

	/**
	 * 设置点击选中的汽车颜色
	 */
	public void setDownCarTypeColor(int position) {
		if (list_layout.get(position).isEnabled()
				&& Integer.parseInt(main.getVtype()) != Value.vtype_null) {
			list_icon.get(position).setImageDrawable(
					mainActivity.getResources().getDrawable(
							icon_car_down[position]));
			list_text.get(position).setTextColor(
					mainActivity.getResources().getColor(R.color.blue));
		}
	}

	@Override
	public void onComboFinish(String messgae) {
		if (messgae != null) {
			this.old_position = cb_position;
			if (!messgae.equals("")) {
				tv_combo.setVisibility(View.VISIBLE);
				tv_combo.setText(messgae);
			} else {
				tv_combo.setVisibility(View.GONE);
			}
			main.setComboPrice(messgae);

			isautomatic = false;
			//设置默认车型，只有第一辆车
			if (Integer.parseInt(main.getVtype())==Value.list_vtype[0]) {
				main.setDefaultCar(main.getLevelCar(), main.getSeat_num(),
						main.getVtype(), main.getVtypeId(), main.getTc_id(),
						messgae, main.getVtypeTitle());
			}
			main.setPrevCar(main.getLevelCar(), main.getSeat_num(),
					main.getVtype(), main.getVtypeId(), main.getTc_id(),
					messgae, main.getVtypeTitle());
			// 添加汽车具体的类型文字说明
			setCarTextBule(cb_position);

		} else {// 获取失败，则返回上一个车型
			setPrevCar(1);
		}
	}

	@Override
	public void OnActivityResulFinish() {
		setDefaultCar();
	}

	/**
	 * 添加汽车具体的类型文字说明
	 */
	public void setCarTextBule(int position) {
		String[] split_vtypetitle = main.getVtypeTitle().split(" ");
		if (split_vtypetitle != null && split_vtypetitle.length >= 2) {
			list_text.get(position).setText(
					split_vtypetitle[0] + "(" + split_vtypetitle[1] + ")");
		}
	}

	public void addPoint() {
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				// 添加途经点
				View view_point = LayoutInflater.from(mContext).inflate(
						R.layout.item_point, null);
				int start = 2;
				if (list_point.size() > 0) {
					start = start + list_point.size();
				}
				layout_parent.addView(view_point, start);
				list_point.add((SwipeLayout) view_point);
				addPointListener();
				new Handler().postAtTime(new Runnable() {
					
					@Override
					public void run() {
						hideMenuDel();
					}
				}, 5000);
			}
		}, 100);

	}

	public void removePoint(View v) {
		// 移除途经点
		layout_parent.removeView(v);
		list_point.remove(v);
		open_id = -1;
		addPointListener();
	}


	public void showMenuDel(int position) {
		int closeid = open_id;
		open_id = position;
		if (closeid != position && closeid >= 0 && closeid < list_point.size()) {
			list_point.get(closeid).close();
		}

	}

	/**
	 * 隐藏途经点的删除菜单，并把open_id清空，
	 */
	public void hideMenuDel() {
		if (open_id >= 0 && open_id < list_point.size()) {
			list_point.get(open_id).close();
			open_id = -1;
		}
	}

	@Override
	public boolean onTouch(MotionEvent ev) {
		if (ev.getAction() == MotionEvent.ACTION_DOWN) {
			//如果有打开项，则判断是否在区域外
			if (open_id >= 0 && open_id < list_point.size()) {
				RelativeLayout layout_point = (RelativeLayout) list_point.get(
						open_id).findViewById(R.id.layout_point);
				//区域外则可以打开右滑动菜单
				if (IsViewOutArea.isViewOutArea(layout_point, ev)) {
					mainActivity.mMenuDrawer
							.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
				} 
				//区域内则不打开右滑动菜单
				else {
					mainActivity.mMenuDrawer
							.setTouchMode(MenuDrawer.TOUCH_MODE_NONE);
				}
			} 
			//如果没有打开项则可以打开右滑动菜单
			else {
				mainActivity.mMenuDrawer
						.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
			}
			//【注意】每执行一次动作要移除监听，，不然会出现死循环，只要在down途径点的时候在添加一次监听即可
			mainActivity.unregisterMyOnTouchListener(this);
			return mainActivity.dispatchTouchEvent(ev);
		}
		// 必不可少，否则所有的组件都不会有TouchEvent了
		if (mainActivity.getWindow().superDispatchTouchEvent(ev)) {
			return true;
		}
		return mainActivity.onTouchEvent(ev);
	}

	@Override
	public void onScrollChanged(int fangxiang) {
		switch(fangxiang){
		case MyHorizontalScrollView.LEFT:
			iv_more_left.setVisibility(View.GONE);
			iv_more_right.setVisibility(View.VISIBLE);
			break;
		case MyHorizontalScrollView.RIGHT:
			iv_more_left.setVisibility(View.VISIBLE);
			iv_more_right.setVisibility(View.GONE);
			break;
		case MyHorizontalScrollView.CENTER:
			break;
		}
		
	}

	@Override
	public void onSwitchButton(boolean opened) {
		showIsOwn();
		//切换的时候重新获取该车型的第一个
		MyVclassTask.getInstance(mainActivity, mApplication,
				cb_position, Integer.parseInt(main.getVtype()),
				0, true).setOnVclassListener(
				OfficialFragment.this);
////      
//		if(mainActivity.map_vclass.get(Integer.parseInt(main.getVtype()))!=null)
//		onVclass(cb_position,Integer.parseInt(main.getVtype()), 0,mainActivity.map_vclass.get(Integer.parseInt(main.getVtype())),true);
	}
	public void showIsOwn(){
		if (main.getOwn_expense() == Value.OWN) {
			layout_message.setVisibility(View.GONE);
			layout_wf.setVisibility(View.GONE);
		}else if (main.getOwn_expense() == Value.NOOWN) {
			layout_message.setVisibility(View.VISIBLE);
			layout_wf.setVisibility(View.VISIBLE);
		}
	}
}
